

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;


CREATE SCHEMA s_user;


COMMENT ON SCHEMA s_user IS 'User Admin';


SET search_path = s_user, pg_catalog;

CREATE FUNCTION created_at_function() RETURNS trigger
LANGUAGE plpgsql
AS $$
declare
  t timestamptz;
BEGIN
  t := now();
  NEW.created_at = t;
  NEW.updated_at = t;
  RETURN NEW;
END;
$$;


CREATE FUNCTION updated_at_function() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
  NEW.updated_at = clock_timestamp();
  RETURN NEW;
END;
$$;


SET default_tablespace = '';

SET default_with_oids = false;


CREATE TABLE databasechangelog (
  id character varying(255) NOT NULL,
  author character varying(255) NOT NULL,
  filename character varying(255) NOT NULL,
  dateexecuted timestamp without time zone NOT NULL,
  orderexecuted integer NOT NULL,
  exectype character varying(10) NOT NULL,
  md5sum character varying(35),
  description character varying(255),
  comments character varying(255),
  tag character varying(255),
  liquibase character varying(20),
  contexts character varying(255),
  labels character varying(255),
  deployment_id character varying(10)
);



CREATE TABLE databasechangeloglock (
  id integer NOT NULL,
  locked boolean NOT NULL,
  lockgranted timestamp without time zone,
  lockedby character varying(255)
);


DROP TABLE IF EXISTS "s_user"."t_user";
CREATE TABLE "s_user"."t_user" (
  "id" BIGSERIAL NOT NULL ,
  "source" int2 NOT NULL DEFAULT 1,
  "status" int2 NOT NULL DEFAULT 1,
  "tel" varchar(11) COLLATE "pg_catalog"."default",
  "temp_tel" VARCHAR(11) COLLATE "pg_catalog"."default",
  "verify_code" varchar(10) COLLATE "pg_catalog"."default",
  "password" text COLLATE "pg_catalog"."default",
  "openid" text COLLATE "pg_catalog"."default" NOT NULL,
  "code" text COLLATE "pg_catalog"."default",
  "created_at" timestamptz(6) NOT NULL,
  "updated_at" timestamptz(6) NOT NULL,
  "deleted_at" timestamptz(6),
  "nick_name" varchar(20) COLLATE "pg_catalog"."default",
  "avatar" text COLLATE "pg_catalog"."default"
)
;

CREATE TRIGGER "created_at_user_trigger" BEFORE INSERT ON "s_user"."t_user"
  FOR EACH ROW
EXECUTE PROCEDURE "s_user"."created_at_function"();
CREATE TRIGGER "updated_at_user_trigger" BEFORE INSERT ON "s_user"."t_user"
  FOR EACH ROW
EXECUTE PROCEDURE "s_user"."updated_at_function"();

ALTER TABLE "s_user"."t_user" ADD CONSTRAINT "t_user_pkey" PRIMARY KEY ("id");



